<template>
  <div class="cardContainer">
    <!-- <div class="subscribe">
      <el-button size="mini" @click.native="Subscribe(cardData)" style="transform:scale(0.6,0.6);">
        <i :class="[ cardData.subscribeid? 'el-icon-star-on': 'el-icon-star-off' ] "></i>
      </el-button>
    </div> -->
    <div class="cardLeft">
      <img :src="cardData.cetAppicon" alt="图片载入失败">
    </div>
    <div class="cardRight">
      <div
        class="cardTitle"
        :title="cardData.cetAppname"
        @click="href(cardData.cetInneraddress)"
      >{{ cardData.cetAppname }}</div>
      <div class="cardDesc" :title="cardData.appdesc">
        <div>{{ cardData.appdesc }}</div>
      </div>
    </div>
    <div style="clear:both;"/>
  </div>
</template>

<script>
import { editAppSubscribe } from "@/api/home";
export default {
  props: {
    cardData: {
      cetAppname: "测试title",
      appdesc: "测试描述"
    }
  },
  data() {
    return {};
  },
  methods: {
    href(url) {
      window.open(this.BASE_ADDR + url);
    },
    Subscribe(appId) {
      // 订阅动作
      // cardData.subscribeid
      editAppSubscribe(appId.id).then(res => {
        if (res.type === "add") {
          this.cardData.subscribeid = 0;
        } else {
          this.cardData.subscribeid = 1;
        }
        this.$notify({
          title: "成功",
          message: res.msg,
          type: "success",
          offset: 100
        });
      });
      return false;
    }
  }
};
</script>

<style lang="scss" scoped>
$cardImgH: 44px;
.cardContainer {
  width: 230px;
  height: auto;
  padding: 14px;
  margin: 10px 0;
  border: 1px solid #e8e8e8;
  cursor: pointer;
  position: relative;
  .subscribe {
    width: auto;
    position: absolute;
    right: -9px;
    top: -7px;
  }
  .cardLeft {
    width: $cardImgH;
    height: $cardImgH;
    float: left;
    img {
      width: $cardImgH;
      height: $cardImgH;
      border-radius: 50%;
    }
  }
  .cardRight {
    margin-left: 60px;
    .cardTitle {
      height: 24px;
      line-height: 24px;
      font-size: 14px;
      font-weight: 400;
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
      cursor: pointer;
    }
    .cardDesc {
      font-size: 12px;
      color: #e8e8e8;
      cursor: pointer;
      div {
        width: auto;
        max-width: 30%;
        height: 20px;
        line-height: 20px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        float: left;
      }
    }
  }
}
</style>
